import requests

from config import HOST
from tools import GetLog

logger = GetLog.get_logger()
class ApiRecharge:
    def __init__(self,session):
        # 1、初始化session对象
        self.session = session
        # 2、充值图片验证码
        self.__img_code =  HOST + "/common/public/verifycode/{}"
        # 3、请求后台充值URL
        self.__recharge_url = HOST + "/trust/trust/recharge"
        # 4、请求后台投资
        self.__invest_url = HOST + "/trust/trust/tender"
    # 充值图片验证码接口 封装
    def api_img_code(self,num):
        logger.info("正在调用充值图片验证码接口,请求方法:GET,请求URL:{}".format(self.__img_code.format(num)))
        return self.session.get(url = self.__img_code.format(num))
    # 请求后台充值接口 封装
    def api_recharge(self,paymentType="chinapnrTrust",amount="10000",formStr="reForm",valicode="8888"):
        data = {
            "paymentType":paymentType,
            "amount":amount,
            "formStr":formStr,
            "valicode":valicode
        }
        logger.info("正在调用请求后台充值接口,请求方法:POST,请求URL:{},请求参数:{}".format(self.__recharge_url,data))
        return self.session.post(url = self.__recharge_url,data=data)